﻿using System;
using fastCSharp;

namespace diantou.web.contest
{
    /// <summary>
    /// 编辑比赛
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class edit : permissionView<edit>
    {
        /// <summary>
        /// 比赛
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.dataAccess.contest contest;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="contestId"></param>
        /// <returns></returns>
        private bool loadView(int contestId)
        {
            if ((currentUser.Permission & dataModel.user.permission.ContestEditor) != 0)
            {
                if (contestId == 0)
                {
                    DateTime now = date.NowSecond;
                    contest = diantou.dataAccess.contest.NullContest;
                    contest.StartTime = new DateTime(now.Year, now.Month, now.Day).AddDays(1);
                    contest.EndTime = contest.StartTime.AddDays(1);
                    return true;
                }
                contest = diantou.dataAccess.clientCache.Contest[contestId];
                if (contest != null && (currentUser.Permission == dataModel.user.permission.Admin || contest.UserId == currentUserId)) return true;
            }
            AjaxResponse(webConfig.NotFound404);
            return false;
        }
    }
}
